package driver

import (
	"cloud-export-iotkit-mqtt/pkg/config"
	"cloud-export-iotkit-mqtt/pkg/core"
	"cloud-export-iotkit-mqtt/pkg/msg"
	"github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger"
	"time"
)

type ProtocolServiceChanel interface {
	Initialize(logger *logger.LoggingClient, mqttConfig config.MQTTConfig,
		connectHandler ConnectCallback, onConnectLostHandler ConnectLostCallback) (err error)

	Connect()

	// Subscribe 订阅
	Subscribe(topic string, callback MessageCallback) core.Result
	// Publish 发布
	Publish(topic string, qos byte, payload interface{}, timeout time.Duration) core.Result

	// Destroy 销毁驱动
	Destroy() error
}

type MessageCallback func(data msg.Message)

type ConnectCallback func(ch ProtocolServiceChanel)
type ConnectLostCallback func(ch ProtocolServiceChanel, err error)
